import { defineConfig } from "vite";
import path from "path";
import Vue from "@vitejs/plugin-vue";
import Unocss from "unocss/vite";
import Pages from "vite-plugin-pages";
import { presetUno, presetAttributify,presetIcons } from "unocss";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import Layouts from "vite-plugin-vue-layouts";
import VueI18n from "@intlify/vite-plugin-vue-i18n";
export default defineConfig({
  resolve: {
    alias: {
      "~/": `${path.resolve(__dirname, "src")}/`,
    },
  },
  plugins: [
    Vue({
      include: [/\.vue$/],
    }),
    Unocss({
      presets: [presetUno(), presetAttributify(), presetIcons()],
    }),
    Pages({
      exclude: ["**/components/*.vue"], //不让这个层级配置路由
      extensions: ["vue"],
    }), //配置路由
    Layouts(),
    AutoImport({
      // 按要导入插件
      imports: ["vue", "vue-i18n", 'vue-router',"pinia","@vueuse/core","@vueuse/head"],
      dts: "src/auto-imports.d.ts",//自动生成auto-imports.d.ts文件
      vueTemplate: true, //支持Vue 模版自动引入
      dirs: [
        'src/composables',
      ],
    }),
    Components({
      // 按要导入组件
      dirs: [
        "src/components",
        "src/pages/**/components", //在pages目录下任何一级都支出
      ],
      extensions: ["vue"],
      include: [/\.vue$/],
      dts: "src/components.d.ts", //自动生成components.d.ts文件
    }),
    VueI18n({
      runtimeOnly: true,
      compositionOnly: true,
      include: [path.resolve(__dirname, "locales/**")]
    }),
  ],
});
